package com.qf.fc.controller;


import com.qf.fc.Param.UserDetailUpdate;
import com.qf.fc.entity.UserDetail;
import com.qf.fc.service.UserDetailService;
import com.qf.fc.utils.AliOSSUtils;
import com.qf.fc.vo.R;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * 用户详情表(UserDetail)表控制层
 *
 * @author makejava
 * @since 2024-09-16 22:56:04
 */
@RestController
@RequestMapping("/api/uDetail")
@Tag(name="用户详情接口")  //knife4j 接口文档
@Slf4j
public class UserDetailController{
    /**
     * 服务对象
     */
    @Resource
    private UserDetailService service;
    @Autowired
    private AliOSSUtils aliOSSUtils;

    @PostMapping("/updatedetail")
    public R<UserDetail>  update(@RequestBody UserDetailUpdate userDetailUpdate){
        return service.update(userDetailUpdate);
    }
    @PostMapping("/updateimg")
    public R<UserDetail>  updateImg(@RequestPart MultipartFile file, HttpServletRequest request, Integer id) throws IOException {
        String img_url = aliOSSUtils.upload(file);
        log.info("处理后的图像地址为：{}",img_url);
        return service.updateImg(file,img_url,id);
    }
}

